﻿@{
   Layout = null;
}

<!DOCTYPE html>
<html>

<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>@ElingOA6_Admin_DSJCJ.Common.GlobalConstant.CONSTRING_SYSTITLE</title>
<link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/ntko.js", true)" type="text/javascript"></script>
<script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

@Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
@Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)

<script type="text/javascript">



    function MenuTop_emClick(source, e) {
        switch (e.item.name) {
            case "btnSave":
                {
                    //保存
                    var file = FTitle.GetText();
                    if (file == null || ASPxClientUtils.Trim(file) == "") {
                        FTitle.SetErrorText("请填写模板名称");
                        FTitle.SetIsValid(false);
                        return;
                    }

                    saveFileToUrl(file);

                    break;
                }
            case "btnClose":
                {
                    //关闭
                    window.close();
                    break;
                }
        }
    }

</script>
</head>
<body onload='editoffice("@ViewData["url"]","@ViewData["newOfficeType"]");'>
@using (Html.BeginForm("", "", FormMethod.Post, new { id = "form1" }))
{ 
<div class="floatToolMenu" id="toolMenu">
       @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

           settings.Items.Add(item =>
           {
               item.Name = "btnSave";
               item.Text = "保存";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/filesave.png");
           });
           settings.Items.Add(item =>
           {
               item.Name = "btnClose";
               item.Text = "关闭";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/no.png");

           });

           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
        </div>           
        
        <table class="tableFrom">
        <tr>
            <th width="100px">模板名称:</th>
            <td>
               @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FTitle";
                   settings.Width = 200;
                   settings.Text = ViewData["title"].ToString();
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
               }).GetHtml()
        
           </td>
            
                 <td>
               @Html.DevExpress().CheckBox(settings =>
               {
                   settings.Name = "FIsDefault";
                   settings.Width = 200;
                   settings.Checked = (bool)ViewData["FIsDefault"];
                   settings.Text = "默认";
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
               }).GetHtml()
        
           </td>
        </tr>
      </table>


       @Html.Hidden("FSourceNo", ViewData["fSourceNo"])
       @Html.Hidden("FTemplateID", ViewData["temID"])
       @Html.Hidden("FTemplateType", ViewData["temType"])
    
    <div>

            <script>
                var ProductCaption = '@ViewData["ProductCaption"]';
                var ProductKey = '@ViewData["ProductKey"]';
                savecode = rootPath + "/Admin/SysTemplate/OfficeTemplateSave";
            </script>

            <script src="@Url.Content("~/Scripts/ntkoofficecontrol.js", true)" type="text/javascript"></script>
            <!--控件事件代码开始-->

            <script type="text/javascript" language="JScript" for="TANGER_OCX" event="OnFileCommand(cmd,canceled);">
	                alert(cmd);
	                CancelLastCommand=true;
            </script>

            <script type="text/javascript" language="JScript" for="TANGER_OCX" event="OnDocumentClosed();">
	                setFileOpenedOrClosed(false);
            </script>

            <script type="text/javascript" language="JScript" for="TANGER_OCX" event="OnDocumentOpened(TANGER_OCX_str,TANGER_OCX_obj);">
	                //saved属性用来判断文档是否被修改过,文档打开的时候设置成ture,当文档被修改,自动被设置为false,该属性由office提供.	                
	                TANGER_OCX_OBJ.ActiveDocument.Saved = true;
	                
	                if(2==TANGER_OCX_OBJ.DocType)
	                {
	                
	                    try{
	                        TANGER_OCX_OBJ.ActiveDocument.Application.ActiveWorkbook.Saved=true;
	                    }catch(e)
	                    {
	                        alert("错误：" + err.number + ":" + err.description);
	                    }
	                 }
	                setFileOpenedOrClosed(true);//设置文档状态值
		            controlStyle();//插入控件样式自定义菜单
		            SetReviewMode(false);//设置文档在痕迹模式下编辑
		       
            </script>

            <script type="text/javascript" language="JScript" for="TANGER_OCX" event="BeforeOriginalMenuCommand(TANGER_OCX_str,TANGER_OCX_obj);">
	                alert("BeforeOriginalMenuCommand事件被触发");
            </script>

            <script type="text/javascript" language="JScript" for="TANGER_OCX" event="OnFileCommand(TANGER_OCX_str,TANGER_OCX_obj);">
	                if (TANGER_OCX_str == 3) 
	                {
		                alert("不能保存！");
		                CancelLastCommand = true;
	                }
            </script>

            <script language="JScript" for="TANGER_OCX" event="OnCustomMenuCmd2(menuPos,submenuPos,subsubmenuPos,menuCaption,menuID)">
		            //alert("第" + menuPos +","+ submenuPos +","+ subsubmenuPos +"个菜单项,menuID="+menuID+",菜单标题为\""+menuCaption+"\"的命令被执行.");
		            if("全网页查看"==menuCaption)objside();
		            if("恢复原大小"==menuCaption)objside2();
            </script>

            <script type="text/javascript" language="JScript" for="TANGER_OCX" event="AfterPublishAsPDFToURL(result,code);">
	                result=trim(result);
	                alert(result);
	                if(result=="succeed")
	                {window.close();}
            </script>

            <!--控件事件代码结束-->
        </div>

    
}
</body>
</html>